﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HtmlAgilityPack;
using Kooboo.HtmlFunc.Function;
using Kooboo.HtmlFunc.Providers;

namespace Kooboo.HtmlFunc.Analysis.Visitors
{
    public class MetaTagVisitor : VisitorBase
    {
        public MetaTagVisitor(VisitorContext context)
            : base(context)
        {
        }

        public override void VisitNode(HtmlNode node)
        {
            if (node.Is("META"))
            {
                if (node.ParentNode.Is("HEAD"))
                {
                    var metaTag = Provider.Factory.GetProvider<IMetaTag>();
                    metaTag.Node = node;
                    this.Context.Result.Metas.Add(metaTag);
                }
            }
        }
    }
}
